﻿using Resn.WhuPub.BIL;
using Resn.WhuPub.DAL;
using Resn.WhuPub.DML;
using System;

namespace Resn.WhuPub.BLL
{
        /// <summary>
        /// 实现差旅的属性和方法
        /// </summary>
        public class Travel :Entity, ITravel
        {
                #region 构造函数

                public Travel(TravelModel model)
                {
                        Model = model;
                }

                #endregion


                #region 属性

                #region 基本属性

                

                /// <summary>
                /// 获取或设置员工标识
                /// </summary>
                /// <value>
                /// 员工标识
                /// </value>
                public string EmployeeId
                {
                        get
                        {
                                return Model.EmployeeId;
                        }
                }

                /// <summary>
                /// 获取或设置计划内容
                /// </summary>
                /// <value>
                /// 计划内容
                /// </value>
                public string PlanContent
                {
                        get
                        {
                                return Model.PlanContent;
                        }
                        set
                        {
                                Model.PlanContent = value;
                        }
                }

                /// <summary>
                /// 获取或设置计划是否已审批
                /// </summary>
                /// <value>
                /// 计划是否已审批
                /// </value>
                public bool IsPlanApproved
                {
                        get
                        {
                                return Model.IsPlanApproved;
                        }
                        set
                        {
                                Model.IsPlanApproved = value;
                        }
                }

                /// <summary>
                /// 获取或设置计划修改意见
                /// </summary>
                /// <value>
                /// 计划修改意见
                /// </value>
                public string PlanModify
                {
                        get
                        {
                                return Model.PlanModify;
                        }
                        set
                        {
                                Model.PlanModify = value;
                        }
                }

                /// <summary>
                /// 获取或设置计划是否已确认
                /// </summary>
                /// <value>
                /// 计划是否已确认
                /// </value>
                public bool IsPlanConfirmed 
                {
                        get
                        {
                                return Model.IsPlanConfirmed;
                        }
                        set
                        {
                                Model.IsPlanConfirmed = value;
                        }
                }

                /// <summary>
                /// 获取或设置计划借款金额
                /// </summary>
                /// <value>
                /// 计划借款金额
                /// </value>
                public Double LendAmount
                {
                        get
                        {
                                return Model.LendAmount;
                        }
                        set
                        {
                                Model.LendAmount = value;
                        }
                }

                /// <summary>
                /// 获取或设置开始时间
                /// </summary>
                /// <value>
                /// 开始时间
                /// </value>
                public DateTime StartTime
                {
                        get
                        {
                                return Model.StartTime;
                        }
                        set
                        {
                                Model.StartTime = value;
                        }
                }

                /// <summary>
                /// 获取或设置结束时间
                /// </summary>
                /// <value>
                /// 结束时间
                /// </value>
                public DateTime EndTime
                {
                        get
                        {
                                return Model.EndTime;
                        }
                        set
                        {
                                Model.EndTime = value;
                        }
                }

                /// <summary>
                /// 获取或设置备注
                /// </summary>
                /// <value>
                /// 备注
                /// </value>
                public string Memo
                {
                        get
                        {
                                return Model.Memo;
                        }
                        set
                        {
                                Model.Memo = value;
                        }
                }

                #endregion 基本属性

                /// <summary>
                /// 获取差旅模型
                /// </summary>
                /// <value>
                /// 差旅模型
                /// </value>
                public TravelModel Model { get; private set; }

                

                #endregion 属性

                #region 方法

                /// <summary>
                /// 获取指定标识的对象
                /// </summary>
                /// <param name="id">标识</param>
                /// <returns></returns>
                public static Travel Select(string id)
                {
                        return Select<Travel, TravelModel>(id);
                }
                /// <summary>
                /// 创建拜访
                /// </summary>
                /// <param name="contactId">联系人标识</param>
                /// <param name="startTime">开始时间</param>
                /// <param name="endTime">结束时间</param>
                /// <param name="visitType">拜访方式</param>
                /// <param name="objective">目的</param>
                /// <param name="keyPoints">要点</param>
                /// <param name="eatAmount">宴请金额</param>
                /// <param name="giftAmount">礼品金额</param>
                /// <param name="memo">备注</param>
                /// <returns>
                /// 创建的拜访对象
                /// </returns>
                public ITravelVisit CreateTravelVisit(string contactId, DateTime startTime, DateTime endTime, VisitType visitType,
                                                      string objective, string keyPoints, double eatAmount, double giftAmount, string memo)
                {
                        var model = new TravelVisitModel
                                {
                                        Id = Guid.NewGuid().ToString(),
                                        ContactId = contactId,
                                        StartTime = startTime,
                                        EndTime = endTime,
                                        VisitType = visitType.ToString(),
                                        Objective = objective,
                                        KeyPoints = keyPoints,
                                        EatAmount = eatAmount,
                                        GiftAmount = giftAmount,
                                        EnteringTime = DateTime.Now,
                                        Memo = memo
                                };
                        return new TravelVisit(model);
                }

                
                #endregion

        }
}